function ValidateEmail(email) {
  var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
  return emailPattern.test(email);
}

function hasClass(ele, cls) {
  return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
}

function addClass(ele, cls) {
  if (!this.hasClass(ele, cls)) ele.className += "  " + cls;
}

function removeClass(ele, cls) {
  if (hasClass(ele, cls)) {
    var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
    ele.className = ele.className.replace(reg, ' ');
  }
}

function AllowNumber(s, e) {
  var keyCode = e.keyCode;
  if (keyCode > 31 && (keyCode < 48 || (keyCode > 57 && (keyCode < 96 || keyCode > 105)))) {
    return false;
  }
  return true;
}

function SetMaxLength(e, stringValue, maxLength) {
  var keyCode = e.keyCode;
  if (keyCode == 8 && keyCode == 46)  //delete key
    return true;
  if (stringValue == null || maxLength == null)
    return true;
  var length = stringValue.length;
  if (length <= maxLength)
    return true;
  return false;
}

//checking wheter date1 greater than date2 or not
function IsGreaterDate(date1, date2) {
  if (date1 == null || date2 == null)
    return false;
  var date1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
  var date2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
  if (date1 < date2)
    return false;
  return true;
}
 